<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../libs/vue.js"></script>
    <style>
        .btn {
            width: 100px;
            height: 50px;
            border: 1px solid #000;
            text-align: center;
            line-height: 50px;
            font-size: 20px;
            cursor: pointer;
        }
        .btn-list {
            display: flex;
        }
        .content {
            width: 300px;
            height: 200px;
            border: 10px dotted pink;
        }
        /* 高亮类名 */
        .active {
            background-color: pink;
            color: #fff;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="btn-list">
            <div class="btn" :class="flag==1?'active':''" @click="toggle(1)">首页</div>
            <div class="btn" :class="flag==2?'active':''" @click="toggle(2)">新闻</div>
            <div class="btn" :class="flag==3?'active':''" @click="toggle(3)">关于</div>
        </div>
        <div class="content-list">
            <div class="content" v-show="flag==1">首页</div>
            <div class="content" v-show="flag==2">新闻</div>
            <div class="content" v-show="flag==3">关于</div>
        </div>
    </div>
    <script>
        // vue核心：数据驱动，组件系统
        let vm = new Vue({
            el:'#app',
            data:{
                flag:1
            },
            methods: {
                toggle(index) {
                    this.flag = index
                }
            },
        })
    </script>
</body>
</html>